<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample</title>
<meta name="viewport"
            content="width=device-width, initial-scale=1.0">
<meta name="HandheldFriendly" content="true">
</head>
<body>
<canvas id="myCanvas" width="300" height="150"
        style="border:1px dashed #c3c3c3;">
   这里放置的内容用于浏览器不支持Canvas的情况
</canvas>
<script>
var canvas =document.getElementById("myCanvas");
if (canvas && canvas.getContext) {
   var cxt = canvas.getContext("2d");
   // 创建放射状渐变
   var grd = cxt.createRadialGradient(150,75,0,150,75,100);
   // 添加两个颜色点
   grd.addColorStop(0,"#FF0000");
   grd.addColorStop(1,"#00FF00");
   // 指定线性渐变填充
   cxt.fillStyle = grd;
   // 绘图
   cxt.beginPath();
   cxt.arc(150, 75, 100, 0, Math.PI*2, true);
   cxt.closePath();
   cxt.fill();
}
</script>
</body>
</html>
